package com.kexio.user.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import jakarta.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * 刷新令牌请求DTO
 * 
 * 用于刷新访问令牌的请求参数
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RefreshTokenRequest implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 刷新令牌
     */
    @NotBlank(message = "刷新令牌不能为空")
    private String refreshToken;
    
    /**
     * 租户ID（多租户场景）
     */
    private String tenantId;
    
    /**
     * 客户端设备信息
     */
    private String deviceInfo;
    
    /**
     * 客户端IP地址（由服务端自动获取，客户端无需传入）
     */
    private String clientIp;
    
    /**
     * User-Agent信息（由服务端自动获取，客户端无需传入）
     */
    private String userAgent;
    
    // ==================== 构造函数 ====================
    
    public RefreshTokenRequest() {}
    
    public RefreshTokenRequest(String refreshToken) {
        this.refreshToken = refreshToken;
    }
    
    public RefreshTokenRequest(String refreshToken, String tenantId) {
        this.refreshToken = refreshToken;
        this.tenantId = tenantId;
    }
    
    // ==================== 便捷方法 ====================
    
    /**
     * 判断是否为多租户请求
     */
    public boolean isMultiTenant() {
        return tenantId != null && !tenantId.trim().isEmpty();
    }
    
    /**
     * 判断是否有设备信息
     */
    public boolean hasDeviceInfo() {
        return deviceInfo != null && !deviceInfo.trim().isEmpty();
    }
    
    // ==================== Getter/Setter ====================
    
    public String getRefreshToken() {
        return refreshToken;
    }
    
    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }
    
    public String getTenantId() {
        return tenantId;
    }
    
    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }
    
    public String getDeviceInfo() {
        return deviceInfo;
    }
    
    public void setDeviceInfo(String deviceInfo) {
        this.deviceInfo = deviceInfo;
    }
    
    public String getClientIp() {
        return clientIp;
    }
    
    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }
    
    public String getUserAgent() {
        return userAgent;
    }
    
    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }
    
    @Override
    public String toString() {
        return "RefreshTokenRequest{" +
                "refreshToken='[PROTECTED]'" +
                ", tenantId='" + tenantId + '\'' +
                ", deviceInfo='" + deviceInfo + '\'' +
                ", clientIp='" + clientIp + '\'' +
                ", userAgent='" + userAgent + '\'' +
                '}';
    }
}
